'''
Author: mypx
Date: 2025-10-21 15:28:55
LastEditTime: 2025-10-21 15:31:40
LastEditors: mypx mypx_coder@163.com
Description: 
'''
# 帮助信息模块
from PyQt6.QtWidgets import QPushButton, QToolTip, QDialog, QTextEdit, QVBoxLayout, QDialogButtonBox
from PyQt6.QtCore import Qt

class HelpDialog(QDialog):
    """帮助对话框"""
    def __init__(self, help_text: str, parent: QWidget = None):
        super().__init__(parent)
        self.setWindowTitle("Help")
        self.setMinimumSize(400, 300)
        
        layout = QVBoxLayout(self)
        
        self.text_edit = QTextEdit()
        self.text_edit.setPlainText(help_text)
        self.text_edit.setReadOnly(True)
        layout.addWidget(self.text_edit)
        
        button_box = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok)
        button_box.accepted.connect(self.accept)
        layout.addWidget(button_box)

class HelpModule:
    """帮助信息模块"""
    
    @staticmethod
    def create_help_button(help_text: str, parent: QWidget = None) -> QPushButton:
        """创建帮助按钮"""
        button = QPushButton("?")
        button.setFixedSize(20, 20)
        button.setToolTip("Show help")
        
        def show_help():
            dialog = HelpDialog(help_text, parent)
            dialog.exec()
        
        button.clicked.connect(show_help)
        return button